package com.customer.controller;

import com.customer.service.MemberLevelService;
import com.nameless.entity.MemberLevel;
import com.nameless.vo.MemberLevelVo;
import com.nameless.vo.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author WHZ
 * @date 2023年02月28日 9:55
 */
@RestController
@RequestMapping("/client/level/controller")
public class MemberLevelController {

    @Autowired
    private MemberLevelService memberLevelService;

    /**
     * 分页，模糊查询
     * @param currentPage
     * @param pageSize
     * @param memberLevelVo
     * @return
     */
    @PostMapping("/list")
    public Result<List<MemberLevel>> list(Integer currentPage, Integer pageSize, @RequestBody MemberLevelVo memberLevelVo){
        return memberLevelService.findAll(currentPage, pageSize,memberLevelVo);
    }

    /**
     * 添加
     * @param memberLevel
     * @return
     */
    @PostMapping("save")
    public Result save(@RequestBody MemberLevel memberLevel){
        return memberLevelService.add(memberLevel);
    }

    /**
     * 删除
     * @param id
     * @return
     */
    @DeleteMapping("delete")
    public Result delete(Integer id) {
        return memberLevelService.del(id);
    }

    /**
     * 修改
     * @param memberLevel
     * @return
     */
    @PutMapping("updateById")
    public Result update(@RequestBody MemberLevel memberLevel){
        return memberLevelService.put(memberLevel);
    }
}
